package com.kaili.common.exception;

import com.kaili.common.exception.IResponseStatus;

public class BaseExcept extends RuntimeException {
    private IResponseStatus responseStatus;

    public BaseExcept(IResponseStatus responseStatus) {
        this.responseStatus = responseStatus;
    }

    public BaseExcept(final int code,final String msg) {
        IResponseStatus responseStatus = new IResponseStatus() {
            @Override
            public int getCode() {
                return code;
            }

            @Override
            public String getMsg() {
                return msg;
            }
        };
        this.responseStatus = responseStatus;
    }

    public BaseExcept(final IResponseStatus responseStatus, final String msg) {
        IResponseStatus iResponseStatus = new IResponseStatus() {
            @Override
            public int getCode() {
                return responseStatus.getCode();
            }

            @Override
            public String getMsg() {
                return msg + responseStatus.getMsg();
            }
        };
        this.responseStatus = iResponseStatus;
    }

    public IResponseStatus getResponseStatus() {
        return responseStatus;
    }

    public void setResponseStatus(IResponseStatus responseStatus) {
        this.responseStatus = responseStatus;
    }
}
